package com.javasm.commons;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    public MyResult exceptionHandle(Exception e){
        e.printStackTrace();
        if (e instanceof IllegalAccessException)return new MyResult(403,e.getMessage());
        return new MyResult(500,"系统错误");
    }
}
